﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using diploma.core.data;
using diploma.core.data.objects;

namespace diploma.core
{
    public enum DataSourceTypes : int
    {
        FireBird = 1,
        Unknow = 2
    }

    public class DataProvider
    {
        private DataProvider() { }

        private static DataProvider instance = null;
        
        #region Data Objects Lists
        
        private DataList<Property> properties;
        public DataList<Property> Properties
        {
            get
            {
                return properties;
            }
        }

        private DataList<Method> methods;
        public DataList<Method> Methods
        {
            get
            {
                return methods;
            }
        }

        private DataList<ObjectType> objectTypes;
        public DataList<ObjectType> ObjectTypes
        {
            get
            {
                return objectTypes;
            }
        }

        private DataList<Problem> problems;
        public DataList<Problem> Problems
        {
            get
            {
                return problems;
            }
        }

        private DataList<Question> questions;
        public DataList<Question> Questions
        {
            get
            {
                return questions;
            }
        }

        private DataList<Statement> statements;
        public DataList<Statement> Statements
        {
            get
            {
                return statements;
            }
        }

        private DataList<Term> terms;
        public DataList<Term> Terms
        {
            get
            {
                return terms;
            }
        }

        private DataList<Theme> themes;
        public DataList<Theme> Themes
        {
            get
            {
                return themes;
            }
        }

        private DataList<Theorem> theorems;
        public DataList<Theorem> Theorems
        {
            get
            {
                return theorems;
            }
        }
        #endregion

        public static DataProvider Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new DataProvider();
                }
                return instance;
            }
        }

        DataSource dataSource = null;
        public void AttachDataSource(IEnumerable<string> _settings, DataSourceTypes _dataSourceType)
        {
            switch (_dataSourceType)
            {
                case DataSourceTypes.FireBird:
                    dataSource = new FireBirdDataSource(_settings);
                    break;
                case DataSourceTypes.Unknow:
                default:
                    dataSource = new UnknowDataSource(_settings);
                break;
            }
            

            #region Fill Data Objects

            DataRouter.Instance.AttachDataSource(dataSource);

            /*properties = new DataList<Property>(DataObjectTypes.Property);
            questions = new DataList<Question>(DataObjectTypes.Question);
            terms = new DataList<Term>(DataObjectTypes.Term);
            theorems = new DataList<Theorem>(DataObjectTypes.Theorem);
            statements = new DataList<Statement>(DataObjectTypes.Statement);
            problems = new DataList<Problem>(DataObjectTypes.Problem);
            themes = new DataList<Theme>(DataObjectTypes.Theme);*/
            //            methods = new DataList<Method>(DataObjectTypes.Method);
            /*objectTypes = new DataList<ObjectType>(DataObjectTypes.ObjectType);
            */

            #endregion

        }
    }
}
